<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0" />
    <title>沃闪购</title>
    <link rel="icon" href="../img/bitbug_favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/normalize.css" />
    <!--<link rel="stylesheet" href="index.css"/>-->
    <!--<link rel="stylesheet" href="../index.css"/>-->
    <link rel="stylesheet" href="../index_format.css" />
    <link rel="stylesheet" href="../css/layer.css" />

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/rem.js"></script>
    <script type="text/javascript" src="../js/tool.js"></script>
    <script>
        document.documentElement.style.height = window.innerHeight + 'px';
    </script>
</head>

<body onload="preventMove()">
    <div class="header">
        <div><img src="../img/wo-logo.png" alt="" /></div>
        <div class="wo-topic t-r">商户注册</div>
    </div>
    <div class="container ">
        <div class="flex-box">
            <div class="choose-bank">
                <form id="registerForm" action="">
                    <ul class="form-list">
                        <li><label for="wo_bankUserName">银行卡户名：</label><input id="wo_bankUserName" name="bank_userName" type="text" value="" autofocus/></li>
                        <li><label for="wo_bankName">银行开户行信息：</label><input id="wo_bankName" name="bank_name" type="text" value="" />
                        </li>
                        <li><label for="wo_bankId">银行卡号：</label><input id="wo_bankId" name="bank_id" type="text" value="" />
                        </li>
                    </ul>
                </form>
                <div class="margin-center"></div>
                <div class="btn-group">
                    <!-- <a href="javascript:layer_cofirm('确认取消注册？');" class="btn-style">上一步</a> -->
                    <a id="reg_submit" href="javascript:;" class="btn-style"> 下一步</a>
                </div>
            </div>
            <!--<div class="register-info hide">-->
            <!--<p>恭喜您，注册成功！</p>-->

            <!--<div><a href="login.html" class="btn-style">返回登录界面</a></div>-->
            <!--</div>-->
        </div>
    </div>
    <script type="text/javascript" src="../js/layer.js"></script>
    <script>
        var rigisterPage = {
            wo_bankUserName: '#wo_bankUserName',
            wo_bankName: '#wo_bankName',
            wo_bankId: '#wo_bankId',
            reg_submit: '#reg_submit',
            //        register_info: '.register-info',
            choose_register: '.choose-register',
            get_code: '#get_code',
            host_server: getServerHost(),
            bank_url: '../json/bank.json',
            registerForm: "#registerForm",
            init: function() {
                this.reisgerPart();
            },
            registerCheck: function() {
                var context = this;

                function testBank(ele) {
                    if ($(ele).val().trim().length == 0) {
                        layer_msg('请填写完全银行信息');
                        return false;
                    } else {
                        return true;
                    }
                }

                //            testPhone();
                //            testIdentify()
                //            checkPassword($('#wo_pwd').val());
                //            testIdeify();
                //            console.log(testPhone() && testIdentify()&& checkPassword($('#wo_pwd').val()) && testIdeify())
                // return testPhone() && checkPassword($('#wo_pwd').val()) && testIdentify();
                return testBank(context.wo_bankUserName) && testBank(context.wo_bankName) && testBank(context.wo_bankId);
            },

            //点击注册按钮提交数据
            reisgerPart: function() {
                var context = this;

                $(context.reg_submit).click(function(e) {
                    e.preventDefault();
                    var postData = {};
                    postData = $(context.registerForm).serializeArray();
                    // console.log(postData)

                    //                postData.push({
                    //                    name: "channelName",
                    //                    value: sessionStorage.getItem('bes_com')
                    //                });
                    postData = arry2json(postData);
                    // console.log(postData)

                    console.log(context.registerCheck())
                    if (context.registerCheck()) {
                        var timer = setTimeout(function() {
                            $.ajax({
                                type: 'post',
                                // url: context.host_server + context.bank_url,
                                url: context.bank_url,
                                data: "phone=" + postData.mobile + "&code=" + postData.code,
                                // contentType: "application/json;charset=UTF-8",
                                dataType: 'json',
                                success: function(response) {
                                    clearTimeout(timer);
                                    timer = null;
                                    if ('200' == response.code) {
                                        console.log(response);
                                        if ('ok' != response.res.rp) {
                                            layer_msg('验证码存在错误，请重新填写');
                                        } else {
                                            layer_msg('登录成功')
                                            $(context.registerForm)[0].reset();
                                            // sessionStorage.setItem('postData', JSON.stringify(postData));
                                            var newTimer = setTimeout(function() {
                                                clearTimeout(newTimer);
                                                newTimer = null;
                                                location.href = "./login.html"
                                            }, 3000)

                                        }
                                    } else if ('999' == response.code) {
                                        layer_msg(response.msg)

                                    } else {
                                        layer_msg('未知错误')
                                    }
                                },
                                error: function() {}
                            })
                        }, 1000)
                    } else {
                        //layer_msg(' 填写信息存在错误请重新填写');
                    }
                })
            }
        }


        function MyToggle(showObj, hideObj, time) {
            $(hideObj).fadeOut(0);
            $(showObj).fadeIn(time);
        }

        rigisterPage.init();
    </script>



</body>

</html>
